library(tidyverse)
library(sjlabelled)
gp_covid <-
read_csv2("./data/ZA5667_v1-1-0.csv") %>%
set_na(na = c(-99, -77, -33, 98))
across() to dichotomize the trust variables hzcy044a:hzcy052a. The value 1 should remain, all others should be 0.
mutate() function and then use recode().
There are several ways of doing that.
table() function.select() to select only the manipulated columns and print the whole data frame using View(), glimpse() or the plain console output.median() function to calculate an aggregated variable of all trust variables for all observations in the data.
rowwise() on your data and calculate the values, amongst others, applying the c_across() function. Oh, and don’t forget to finally use ungroup.